$title Stylized Johansen model

* ------------------------------------------------------------------------------
* Model from Chapter 3 of the text "Notes and Problems in Applied General
* Equilibrium Economics" by Dixon, Parmenter, Powell and Wilcoxen (1992).
* Laurent Cretegny, CoPS, Monash University, Australia, 2004.
* ------------------------------------------------------------------------------

sets
  sect              sectors
  fac               factors;

alias (good,sect);

parameters
  dvcomin(good,sect)          dollar value of inputs of commodity good to industry sect
  dvfacin(fac,sect)           dollar value of factor fac used in industry sect
  dvhous(sect)                dollar value of household use of commodity good
  xfac(fac)                   total demand for (or supply of) factor fac;

$gdxin sj
$load sect fac dvcomin dvfacin dvhous
$gdxin

xfac(fac) = sum(sect, dvfacin(fac,sect));

$ontext
$model:sj

$sectors:
  xcom(sect)        ! production
  w                 ! welfare

$commodities:
  pc(sect)          ! price of commodity sect
  pf(fac)           ! price of factor fac
  pw                ! consumer price index

$consumers:
  y                 ! total nominal household expenditure

$prod:xcom(sect)    s:1.0
  o:pc(sect)        q:(sum(good, dvcomin(good,sect)) + sum(fac, dvfacin(fac,sect)))
  i:pc(good)        q:dvcomin(good,sect)
  i:pf(fac)         q:dvfacin(fac,sect)

$prod:w             s:1.0
  o:pw              q:(sum(sect, dvhous(sect)))
  i:pc(sect)        q:dvhous(sect)

$demand:y
  d:pw
  e:pf(fac)         q:xfac(fac)

$report:
  v:c(sect)         i:pc(sect)          prod:w

$offtext
$sysinclude mpsgeset sj

* Benchmark replication

sj.iterlim = 0;
$include sj.gen
solve sj using mcp;
abort$(abs(sj.objval) gt 1e-7) "*** sj does not calibrate ! ***";
sj.iterlim = 1000;

* Fixation of a numeraire to allow comparison

pc.fx("s1") = 1;

* Counterfactual : 10% increase in labor endowment

xfac("labor") = 1.1 * xfac("labor");

$include sj.gen
solve sj using mcp;

* Results

parameters
  res_com           results by commodity in % change from basis
  res_agg           aggregate results in % change from basis; 

res_com("xcom",sect) = (xcom.l(sect) - 1) * 100;
res_com("xh",sect) = (c.l(sect)/dvhous(sect) - 1) * 100;
res_com("pc",sect) = (pc.l(sect) - 1) * 100;

res_agg("welfare") = (w.l - 1 ) * 100;
res_agg("cpi") = (pw.l - 1 ) * 100;
res_agg("y") = (y.l/(sum(sect, dvhous(sect))) - 1 ) * 100;

option decimals = 6;
display res_com, res_agg;
